package com.project.frba.bifront.client.model;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gwt.user.client.rpc.IsSerializable;
import com.project.frba.bifront.client.model.format.Formatter;

public class FrontDescriptor implements IsSerializable{
	
	private String descriptorName;
	private String label;
	private Map<String, String> properties = new HashMap<String, String>();
	private List<String> defaultRows = new ArrayList<String>();
	private List<String> defaultColumns = new ArrayList<String>();
	private Formatter formatter;
	private String filePath;
	

	public FrontDescriptor(){
		
	}
	
	public String getFilePath() {
		return filePath;
	}
	
	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}
	
	public Formatter getFormatter() {
		return formatter;
	}

	public void setFormatter(Formatter formatter) {
		this.formatter = formatter;
	}
	
	public FrontDescriptor(String name){
		this.setDescriptorName(name);
	}
	
	public void setDescriptorName(String name){
		this.descriptorName = name;
	}
	
	public String getDescriptorName(){
		return this.descriptorName;
	}
	
	public void addProperty(String name, String label){
		this.properties.put(label, name);
	}
	
	public Collection<String> getAllPropertiesLabels(){
		return this.properties.keySet();
	}
	
	public String getLabelForProperty(String propertyName){
		for (String propertyLabel: this.properties.keySet()){
			if (this.properties.get(propertyLabel).equals(propertyName)) {
				return propertyLabel;
			}
		}
		return "";
	}
	
	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}
	
	public void addRowDefaultProperty(String propertyName){
		this.defaultRows.add(propertyName);
	}
	
	public void addColumnDefaultProperty(String propertyName){
		this.defaultColumns.add(propertyName);
	}
	
	public List<String> getColumnDefaultProperties(){
		return this.defaultColumns;
	}
	
	public List<String> getRowDefaultProperties(){
		return this.defaultRows;
	}
	
	public List<String> getNotDefaultProperties(){
		List<String> notDefault = new ArrayList<String>();
		for (String property: this.properties.values()) {
			if (!this.defaultColumns.contains(property) && !this.defaultRows.contains(property)) {
				notDefault.add(property);
			}
		}
		return notDefault;
	}
	
	public Collection<String> getAllProperties(){
		return this.properties.values();
	}
	
	

}
